package com.ethan.http;

import com.ethan.http.tgq.TgqRuleInfoParam;
import com.ethan.http.tgq.TgqRuleParam;
import com.ethan.http.tgq.TimePointChargesParam;
import com.google.common.collect.Lists;
import com.qunar.flight.tts.common.JsonUtil;
import qunar.api.pojo.Money;

import java.io.IOException;
import java.util.List;

/**
 * @author ethan
 * create 2018-06-25 下午2:14
 * desc
 **/
public class HttpTest6 {

    public static void main(String[] args) throws IOException {

        String json="{\n" +
                "        \"type\":\"1\",\n" +
                "        \"adultTgqRule\":{\n" +
                "            \"tgqDesc\":\"tgqDesc\",\n" +
                "            \"returnDesc\":\"returnDesc\",\n" +
                "            \"changeDesc\":\"changeDesc\",\n" +
                "            \"signDesc\":\"signDesc\",\n" +
                "            \"viewType\":3,\n" +
                "            \"hasChangePriceTime\":false,\n" +
                "            \"canChange\":false,\n" +
                "            \"canRefund\":false,\n" +
                "            \"cabin\":\"H\",\n" +
                "            \"PercentDesc\":\"PercentDesc\",\n" +
                "            \"basePrice\":30,\n" +
                "            \"timePointChargesList\":[\n" +
                "                {\n" +
                "                    \"time\":31,\n" +
                "                    \"timeDesc\":\"timeDesc\",\n" +
                "                    \"returnFee\":32,\n" +
                "                    \"changeFee\":33\n" +
                "                }\n" +
                "            ]\n" +
                "        },\n" +
                "        \"childTgqRule\":{\n" +
                "            \"tgqDesc\":\"tgqDesc12\",\n" +
                "            \"returnDesc\":\"returnDesc12\",\n" +
                "            \"changeDesc\":\"changeDesc13\",\n" +
                "            \"signDesc\":\"signDesc13\",\n" +
                "            \"viewType\":3,\n" +
                "            \"hasChangePriceTime\":false,\n" +
                "            \"canChange\":false,\n" +
                "            \"canRefund\":false,\n" +
                "            \"cabin\":\"H\",\n" +
                "            \"PercentDesc\":\"PercentDesc12\",\n" +
                "            \"basePrice\":40,\n" +
                "            \"timePointChargesList\":[\n" +
                "                {\n" +
                "                    \"time\":41,\n" +
                "                    \"timeDesc\":\"timeDesc12\",\n" +
                "                    \"returnFee\":42,\n" +
                "                    \"changeFee\":43\n" +
                "                }\n" +
                "            ]\n" +
                "        },\n" +
                "        \"babyTgqDesc\":\"babyTgqDesc\"\n" +
                "    }";
////        TgqRuleInfoParam  tgqRuleInfoParam2=  JsonUtils.deSerialize(json,TgqRuleInfoParam.class);
//        TgqRuleInfoParam  tgqRuleInfoParam2 =  JsonUtil.readObject(json,TgqRuleInfoParam.class);


        String url ="http://l-noahifkag8jw1.auto.beta.cn0.qunar.com:8080/justfortest/updateTgqRuleInfo3";
        List<TgqRuleInfoParam> list = Lists.newArrayList();

        TgqRuleInfoParam tgqRuleInfoParam = new TgqRuleInfoParam();
        tgqRuleInfoParam.setType(1);
        //成人
        TgqRuleParam tgqRuleParam = new TgqRuleParam();
        tgqRuleParam.setBasePrice(Money.of(10));
        List<TimePointChargesParam> timePointChargesParamList = Lists.newArrayList();
        TimePointChargesParam timePointChargesParam = new TimePointChargesParam();
        timePointChargesParam.setChangeFee(Money.of(10));
        timePointChargesParam.setReturnFee(Money.of(20));
        timePointChargesParamList.add(timePointChargesParam);
        tgqRuleParam.setTimePointChargesList(timePointChargesParamList);
        tgqRuleInfoParam.setAdultTgqRule(tgqRuleParam);

        //儿童
        TgqRuleParam childTgqRuleParam = new TgqRuleParam();
        childTgqRuleParam.setBasePrice(Money.of(9));
        List<TimePointChargesParam> childTimePointChargesParamList = Lists.newArrayList();
        TimePointChargesParam childTimePointChargesParam = new TimePointChargesParam();
        childTimePointChargesParam.setChangeFee(Money.of(10));
        childTimePointChargesParam.setReturnFee(Money.of(20));
        childTimePointChargesParamList.add(timePointChargesParam);
        childTgqRuleParam.setTimePointChargesList(childTimePointChargesParamList);
        tgqRuleInfoParam.setChildTgqRule(childTgqRuleParam);



        list.add(tgqRuleInfoParam);
        String aaa = JsonUtil.writeAsString(list);




        String result =  HttpUtils2.postJson(url, json , HttpUtils2.ClientType.NORMAL);

        String str ="";
    }

}
